package com.xiguanlezz.cn.client.naming.event;

import com.xiguanlezz.cn.api.naming.pojo.Instance;
import com.xiguanlezz.cn.common.notify.Event;
import lombok.Getter;

import java.util.List;

/**
 * @Author：习惯了种种
 * @CreateDate：2024/11/28 17:03
 * @Description：服务实例信息变更事件
 */
@Getter
public class InstancesChangeEvent extends Event {
    private static final long serialVersionUID = -7224848922757866084L;

    // 事件作用域标志，这个作用域标志大家暂时忽略，后面马上就会具体展示
    private String eventScope;

    // 订阅的服务名称
    private String serviceName;
    // 分组名称
    private String groupName;
    // 集群名称
    private String clusters;

    // 最新的服务实例信息
    private List<Instance> hosts;

    public InstancesChangeEvent(String serviceName, String groupName, String clusters, List<Instance> hosts) {
        this.serviceName = serviceName;
        this.groupName = groupName;
        this.clusters = clusters;
        this.hosts = hosts;
    }

    public InstancesChangeEvent(String eventScope, String serviceName, String groupName, String clusters, List<Instance> hosts) {
        this.eventScope = eventScope;
        this.serviceName = serviceName;
        this.groupName = groupName;
        this.clusters = clusters;
        this.hosts = hosts;
    }

    @Override
    public String scope() {
        return eventScope;
    }
}
